.class public Lcom/glympse/platform/common/SignaledObject;
.super Ljava/lang/Object;
.source "SignaledObject.java"


# instance fields
.field protected m_nSignalCount:I


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 14
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 16
    const/4 v0, 0x0

    iput v0, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    .line 14
    return-void
.end method


# virtual methods
.method public AddSignal()V
    .locals 1

    .prologue
    .line 43
    const/4 v0, 0x1

    invoke-virtual {p0, v0}, Lcom/glympse/platform/common/SignaledObject;->AddSignals(I)V

    .line 44
    return-void
.end method

.method public AddSignals(I)V
    .locals 1
    .parameter "nCount"

    .prologue
    .line 49
    monitor-enter p0

    .line 51
    :try_start_0
    iget v0, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    add-int/2addr v0, p1

    iput v0, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    .line 53
    const/4 v0, 0x1

    if-le p1, v0, :cond_0

    .line 55
    invoke-virtual {p0}, Ljava/lang/Object;->notifyAll()V

    .line 49
    :goto_0
    monitor-exit p0

    .line 62
    return-void

    .line 59
    :cond_0
    invoke-virtual {p0}, Ljava/lang/Object;->notify()V

    goto :goto_0

    .line 49
    :catchall_0
    move-exception v0

    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0
.end method

.method public Reset()V
    .locals 1

    .prologue
    .line 21
    monitor-enter p0

    .line 23
    const/4 v0, 0x0

    :try_start_0
    iput v0, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    .line 21
    monitor-exit p0

    .line 25
    return-void

    .line 21
    :catchall_0
    move-exception v0

    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0
.end method

.method public Signal()V
    .locals 1

    .prologue
    .line 30
    monitor-enter p0

    .line 32
    :try_start_0
    iget v0, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    if-nez v0, :cond_0

    .line 34
    const/4 v0, 0x1

    iput v0, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    .line 36
    :cond_0
    invoke-virtual {p0}, Ljava/lang/Object;->notify()V

    .line 30
    monitor-exit p0

    .line 38
    return-void

    .line 30
    :catchall_0
    move-exception v0

    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0
.end method

.method public WaitForSignal()Z
    .locals 2

    .prologue
    const/4 v1, 0x1

    .line 67
    monitor-enter p0

    .line 69
    :goto_0
    :try_start_0
    iget v0, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    if-eqz v0, :cond_0

    .line 80
    iget v0, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    if-lez v0, :cond_1

    .line 82
    iget v0, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    sub-int/2addr v0, v1

    iput v0, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    .line 83
    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move v0, v1

    .line 87
    :goto_1
    return v0

    .line 73
    :cond_0
    :try_start_1
    invoke-virtual {p0}, Ljava/lang/Object;->wait()V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0
    .catch Ljava/lang/InterruptedException; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_0

    .line 75
    :catch_0
    move-exception v0

    goto :goto_0

    .line 67
    :cond_1
    :try_start_2
    monitor-exit p0

    .line 87
    const/4 v0, 0x0

    goto :goto_1

    .line 67
    :catchall_0
    move-exception v0

    monitor-exit p0
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    throw v0
.end method

.method public WaitForSignal(J)Z
    .locals 8
    .parameter "lTime"

    .prologue
    const/4 v7, 0x1

    .line 93
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v1

    .line 94
    .local v1, lStart:J
    move-wide v3, p1

    .line 96
    .local v3, lWait:J
    monitor-enter p0

    .line 98
    :goto_0
    :try_start_0
    iget v5, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    if-nez v5, :cond_0

    const-wide/16 v5, 0x0

    cmp-long v5, v3, v5

    if-gtz v5, :cond_1

    .line 111
    :cond_0
    iget v5, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    if-lez v5, :cond_2

    .line 113
    iget v5, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    sub-int/2addr v5, v7

    iput v5, p0, Lcom/glympse/platform/common/SignaledObject;->m_nSignalCount:I

    .line 114
    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move v5, v7

    .line 118
    :goto_1
    return v5

    .line 102
    :cond_1
    :try_start_1
    invoke-virtual {p0, v3, v4}, Ljava/lang/Object;->wait(J)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0
    .catch Ljava/lang/InterruptedException; {:try_start_1 .. :try_end_1} :catch_0

    .line 103
    const-wide/16 v3, 0x0

    goto :goto_0

    .line 105
    :catch_0
    move-exception v0

    .line 107
    .local v0, e:Ljava/lang/InterruptedException;
    :try_start_2
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v5

    sub-long/2addr v5, v1

    sub-long v3, p1, v5

    goto :goto_0

    .line 96
    .end local v0           #e:Ljava/lang/InterruptedException;
    :cond_2
    monitor-exit p0

    .line 118
    const/4 v5, 0x0

    goto :goto_1

    .line 96
    :catchall_0
    move-exception v5

    monitor-exit p0
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    throw v5
.end method
